In graphical applications, colors are specified using controls that reflect the values of color components in various color spaces. Typically, the resulting color is stored in terms of a single canonical color space. FIG. 1 illustrates three exemplary colors spaces: RGB Cube, HSB Cone and HLS Double-cone. Other color spaces exist and are known by those of ordinary skill in the art, however these are not shown in FIG. 1. A color editor control may convert a color between color spaces to allow a user to edit the canonical color in terms of the differing color spaces.
A side effect of the conversion between color spaces is that individual components may be defined in the original space, but undefined in a target color space, depending on the value of the input color. For example, “black” represented in the RGB color space is (0,0,0). The equivalent color expressed in the HSB color space has a well-defined brightness component but undefined hue and saturation components.
A simplistic approach to this problem may be to convert from RGB to HSB and fill-in arbitrary default values for the undefined hue and saturation components. However, the user may have already specified values for these components that are expected to be preserved, even if the components are undefined. FIG. 2 illustrates the problem that results from this simplistic, non-robust approach. In the HSB color space, when the user decreases saturation to zero (see, steps A)-C)), the original hue value is discarded due to an ambiguous conversion. This unexpected behavior is problematic and an inconvenience because as the user moves the saturation level higher (see, steps D) and E)), the hue remains at the arbitrary level assigned by the color editor in step C) (in this case 0). Thus, while only saturation is modified in steps A) and E), hue is changed in step C) and the user is unable to return to the original color in step A).
Accordingly, there is a need for a system that retains values of color components when they are well-defined after color space conversion. When the components are undefined after conversion, the retained values may be used instead of simply choosing an arbitrary default value. The present invention provides such a solution.